/*
 * Copyright (c) 2015 elion. All Rights Reserved.
 */
package com.guoyu.project.web.api;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.google.common.collect.Maps;
import com.guoyu.project.common.pagination.Pagination;
import com.guoyu.project.common.utils.JsonUtil;
import com.guoyu.project.common.web.APIResponse;
import com.guoyu.project.model.Attachment;
import com.guoyu.project.model.Banner;
import com.guoyu.project.service.AttachmentService;
import com.guoyu.project.service.FileUploadService;

@Controller
@RequestMapping("api/attachment")
public class AttachmentApiController{

	private final static Logger logger = LoggerFactory.getLogger(AttachmentApiController.class);

	@Resource
	private AttachmentService attachmentService;

	@RequestMapping("attachmentList")
	@ResponseBody
	public Pagination<Attachment> list(@RequestParam(defaultValue = "0") int offset,
			@RequestParam(defaultValue = "10") int limit, Model model) {
		Map<String, Object> params = Maps.newHashMap();
		 return attachmentService.queryAllAttachment(offset, limit, params);
	}
	@RequestMapping("queryByUserId")
	@ResponseBody
	public Pagination<Attachment> queryByUserId(@RequestParam(defaultValue = "0") int offset,
			@RequestParam(defaultValue = "10") int limit,int userId){
		Map<String,Object> params = Maps.newHashMap();
		params.put("userId",userId);
		return attachmentService.queryAllAttachment(offset, limit, params);
	}

}